package com.yanqu.road.server.cmd.clinic;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.clinic.ClinicProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.clinic.ClinicModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_CLINIC_UPGRADE_DISEASE_ONE_KEY, desc = "医馆病症一键升级")
public class OneKeyUpgradeDiseaseCmd extends AbstractCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ClinicModule.class).upgradeDiseaseOneKey();
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0) {
            ClinicProto.UpgradeDiseaseOneKeyRespMsg.Builder respMsg = ClinicProto.UpgradeDiseaseOneKeyRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_CLINIC_UPGRADE_DISEASE_ONE_KEY, respMsg);
        }
    }
}
